<template>
  <flow-detail
    v-if="inst.id"
    v-model:flow-inst="inst"
    :cancelable="false"
    :actionable="true"
    :commentable="false"
  />
</template>

<script setup>
import { onBeforeMount, onMounted, ref } from "vue";
import FlowInstApi from "@/api/FlowInstApi";
import { setToken } from "@/utils/auth";
import Cookies from "js-cookie";
import { useRouter, useRoute } from "vue-router";
import FlowDetail from "./flow-detail.vue";
const route = useRoute();
const inst = ref({});
onMounted(async () => {
  const { id, token } = route.query;
  if (token) {
    setToken(token);
    Cookies.set("token", token, { SameSite: "strict" });
  }
  console.log("flow id", id);
  if (id) {
    loading.value = true;
    FlowInstApi.getById({ id })
      .then((resp) => {
        loading.value = false;
        if (resp.code == 0) {
          inst.value = resp.data || {};
        }
      })
      .catch(() => (loading.value = false));
  }
});
onBeforeMount(async () => {});
</script>

<style lang="less" scoped>
@import "@/styles/variables.module.less";
</style>
